package com.qf.contract.controller;

import com.qf.common.base.exception.ControllerException;
import com.qf.common.base.exception.ServiceException;
import com.qf.common.base.result.RespResult;
import com.qf.common.base.result.ResultCode;
import com.qf.contract.qo.ContractTerminationQueryQo;
import com.qf.contract.service.ContractTerminationQueryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 合同终止
 */
@Api(tags = "已经终止的合同")
@RestController
@RequestMapping("/contractterminationquery")
public class ContractTerminationQueryController {
    @Resource
    private ContractTerminationQueryService contractTerminationQuery;

    @ApiOperation("合同终止查询")
    @GetMapping("/contractterminationquery")
    @ApiResponses({@ApiResponse(code = 200, message = "成功")})
    public RespResult ContractTerminationQuery(ContractTerminationQueryQo contractTerminationQueryQo, @RequestParam(defaultValue = "1") int current, @RequestParam(defaultValue = "10") int size) {
        //设置默认时间
        try {
//            contractTerminationQueryQo.setWorkArrivalTime(new Date());
            return RespResult.success(contractTerminationQuery.ContractTerminationQuery(contractTerminationQueryQo, current, size));
        } catch (ServiceException e) {
            throw new ServiceException(ResultCode.SYS_ERROR);
        } catch (Exception e) {
            throw new ControllerException(ResultCode.SYS_ERROR);
        }
    }

}
